<%--
  Created by IntelliJ IDEA.
  User: 王志斌
  Date: 2019/2/9
  Time: 20:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    String static_path = path + "/static/alpha";
    String x_admin_path = path + "/static/X-admin-2.3";
%>
<html>
<head>
    <!-- X-admin -->
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <script type="text/javascript" src="<%=x_admin_path%>/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="<%=x_admin_path%>/css/font.css">
    <link rel="stylesheet" href="<%=x_admin_path%>/css/xadmin.css">
    <script type="text/javascript" src="<%=x_admin_path%>/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=x_admin_path%>/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label for="postName" class="layui-form-label">
                <span class="x-red">*</span>岗位名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="postName" required="" lay-verify="required"
                       autocomplete="off" class="layui-input" value="${requestScope.postInfo.postType}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="postTypeList" class="layui-form-label">
                <span class="x-red">*</span>岗位类别
            </label>
            <div class="layui-input-inline">
                <select id="postTypeList" class="valid" lay-search lay-filter="allPostType" lay-verify="required">
                    <option value="">请选择</option>
                    <optgroup label="一级类别">
                        <c:forEach items="${requestScope.postTypeOne}" var="list">
                            <option value="${list.id}"
                                    <c:if test="${requestScope.postInfo.postTypeId.id eq list.id}">
                                        selected="selected"
                                    </c:if>
                            >${list.name}</option>
                        </c:forEach>
                    </optgroup>
                    <optgroup label="二级类别">
                        <c:forEach items="${requestScope.postTypeTwo}" var="list">
                            <option value="${list.id}"
                                    <c:if test="${requestScope.postInfo.postTypeId.id eq list.id}">
                                        selected="selected"
                                    </c:if>
                            >${list.name}</option>
                        </c:forEach>
                    </optgroup>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="departmentList" class="layui-form-label">
                <span class="x-red">*</span>部门
            </label>
            <div class="layui-input-inline">
                <select id="departmentList" class="valid" lay-search lay-filter="allPostType" lay-verify="required">
                    <option value="">请选择</option>
                    <c:forEach items="${requestScope.getAllDepartmentList}" var="list">
                        <option value="${list.id}"
                                <c:if test="${requestScope.postInfo.department.id eq list.id}">
                                    selected="selected"
                                </c:if>
                        >${list.departmentName}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="updateSubmit" lay-submit="">
                修改
            </button>
        </div>
    </form>
</div>
</body>




<script>
    layui.use('form', function() {
        var layer = layui.layer
            , form = layui.form;


        /*修改岗位监听提交*/
        form.on('submit(updateSubmit)', function(data){
            var postName = $("#postName").val();
            var postTypeList = $("#postTypeList").val();
            var departmentVal = $("#departmentList").val();

            //发异步
            layer.alert("修改成功", {icon: 6},function () {

                $.ajax({
                    url:"<%=path%>/manage/department/post_management/updatePost",
                    type:"post",
                    data:{id:${requestScope.postInfo.id},postType:postName,"postTypeId.id":postTypeList,"department.id":departmentVal},
                });





                // 获得frame索引
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
            });
            return false;
        });


    });

</script>
</html>
